
export class GoObj 
{
    constructor(id) {
        this.id = id
    }

    C(name) {
        var paras = []
        for (let i = 0; i < arguments.length ; i ++) {
            if (i>0) {
                paras.push(arguments[i])
            }
        }
        var ret = Window.this.xcall("GoCall", this.id, name, ...paras)

        var i = 0
        var c_ret = []
        for (i = 0; i < ret.length; i++) { 
            var ret_val = ret[i]
            if (typeof ret_val == "object" && "Object" in ret_val) {
                var v_obj = new GoObj(ret_val["Object"])
                c_ret.push(v_obj)
            } else {
                c_ret.push(ret_val)
            }
        }

        if (c_ret.length == 1) {
            return c_ret[0]
        } else {
            return c_ret    
        }
    }
}

export function C_(name) {
    var obj = new GoObj(0)
    return obj.C(...arguments)
}

